/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.awt.GridBagLayout;
import java.io.File;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import libs.Utils;
import panel.PanelFeatureMap;

/**
 *
 * @author musa.atas
 */
public class FrameResultViewer extends javax.swing.JFrame {

    private String currFile = "";
    private String currDir = "";
    public float[][][] xVal3;
    public float[][][] yVal3;
    public float[][] xVal2;
    public float[][] yVal2;
    public String[][] xBands;
    public String[] pepperNames;
    public String[] classLabels;
    public String[] rankedFeatures;
    public String[] rankedFeatureWeights;
    public String[] rankedBands;
    private Vector<String> benchMarkData;  //  @jve:decl-index=0:
    public FrameTestErrorGraph frm;
    int nTrials;
    int nFeatures;
    int nSamples;
    int nTest;
    String benchMarkStr;
    int nBenchMark;
    int nRandom;
    String[] benchMarkColumns = null;
    String[][] benchTrainError = null;
    String[][] benchTestError = null;
    String[][] benchTime = null;

    /**
     * Creates new form FrameResultViewer1
     */
//    public FrameResultViewer() {
//        initComponents();
//    }
    public FrameResultViewer(String currDir) {
        super();
        initComponents();
        this.currDir = currDir;
        //initialize();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane = new javax.swing.JTabbedPane();
        jPanel_mergedGraph = new javax.swing.JPanel();
        jPanel_combination = new javax.swing.JPanel();
        jPanel_combinationGraph = new javax.swing.JPanel();
        jPanel_combinationBands = new panel.PanelFeatureMap();
        jSlider_combinationGraph = new javax.swing.JSlider();
        jPanel_errorFeature = new javax.swing.JPanel();
        jPanel_classificationGraph = new javax.swing.JPanel();
        jPanel_classificationFeatureMap = new panel.PanelFeatureMap();
        jSlider_classification = new javax.swing.JSlider();
        jPanel_prediction = new javax.swing.JPanel();
        jPanel_estimationGraph = new javax.swing.JPanel();
        jPanel_spectralBands = new panel.PanelFeatureMap();
        jPanel_opt = new javax.swing.JPanel();
        jCheckBox_actual = new javax.swing.JCheckBox();
        jCheckBox_est1 = new javax.swing.JCheckBox();
        jCheckBox_est2 = new javax.swing.JCheckBox();
        jCheckBox_est3 = new javax.swing.JCheckBox();
        jCheckBox_avgEst = new javax.swing.JCheckBox();
        jCheckBox_mse = new javax.swing.JCheckBox();
        jCheckBox_totalMSE = new javax.swing.JCheckBox();
        jSlider_estimationBands = new javax.swing.JSlider();
        jSlider_combination = new javax.swing.JSlider();
        jPanel_fM = new javax.swing.JPanel();
        jPanel_featureMap = new panel.PanelFeatureMap();
        jSlider_feature = new javax.swing.JSlider();
        jPanel6 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel_benchNames = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel_benchTestSize = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel_benchRandom = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel_benchTrial = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel_benchFeatures = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel_benchSamples = new javax.swing.JLabel();
        jLabel_benchNumbers = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable_benchTrainError = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable_benchTestError = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable_benchTime = new javax.swing.JTable();
        jPanel_detail = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea = new javax.swing.JTextArea();
        jPanel_options = new javax.swing.JPanel();
        jButton_save = new javax.swing.JButton();

        setTitle("B.Data Visualizer");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        javax.swing.GroupLayout jPanel_mergedGraphLayout = new javax.swing.GroupLayout(jPanel_mergedGraph);
        jPanel_mergedGraph.setLayout(jPanel_mergedGraphLayout);
        jPanel_mergedGraphLayout.setHorizontalGroup(
            jPanel_mergedGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 855, Short.MAX_VALUE)
        );
        jPanel_mergedGraphLayout.setVerticalGroup(
            jPanel_mergedGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 536, Short.MAX_VALUE)
        );

        jTabbedPane.addTab("Merged Graph", jPanel_mergedGraph);

        jPanel_combination.setLayout(new javax.swing.BoxLayout(jPanel_combination, javax.swing.BoxLayout.Y_AXIS));

        jPanel_combinationGraph.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel_combinationGraph.setPreferredSize(new java.awt.Dimension(855, 450));
        jPanel_combinationGraph.setLayout(new java.awt.GridLayout(1, 0));
        jPanel_combination.add(jPanel_combinationGraph);

        jPanel_combinationBands.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel_combinationBands.setLayout(new java.awt.GridBagLayout());
        jPanel_combination.add(jPanel_combinationBands);
        jPanel_combination.add(jSlider_combinationGraph);

        jTabbedPane.addTab("Combination Graph", jPanel_combination);

        jPanel_errorFeature.setLayout(new javax.swing.BoxLayout(jPanel_errorFeature, javax.swing.BoxLayout.Y_AXIS));

        jPanel_classificationGraph.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel_classificationGraph.setPreferredSize(new java.awt.Dimension(855, 487));
        jPanel_classificationGraph.setLayout(new java.awt.GridLayout(1, 0));
        jPanel_errorFeature.add(jPanel_classificationGraph);

        javax.swing.GroupLayout jPanel_classificationFeatureMapLayout = new javax.swing.GroupLayout(jPanel_classificationFeatureMap);
        jPanel_classificationFeatureMap.setLayout(jPanel_classificationFeatureMapLayout);
        jPanel_classificationFeatureMapLayout.setHorizontalGroup(
            jPanel_classificationFeatureMapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 855, Short.MAX_VALUE)
        );
        jPanel_classificationFeatureMapLayout.setVerticalGroup(
            jPanel_classificationFeatureMapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 27, Short.MAX_VALUE)
        );

        jPanel_errorFeature.add(jPanel_classificationFeatureMap);
        jPanel_errorFeature.add(jSlider_classification);

        jTabbedPane.addTab("Classification Graph", jPanel_errorFeature);

        jPanel_prediction.setLayout(new javax.swing.BoxLayout(jPanel_prediction, javax.swing.BoxLayout.Y_AXIS));

        jPanel_estimationGraph.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel_estimationGraph.setPreferredSize(new java.awt.Dimension(855, 400));
        jPanel_estimationGraph.setLayout(new java.awt.GridLayout(1, 0));
        jPanel_prediction.add(jPanel_estimationGraph);

        jPanel_spectralBands.setPreferredSize(new java.awt.Dimension(855, 150));

        javax.swing.GroupLayout jPanel_spectralBandsLayout = new javax.swing.GroupLayout(jPanel_spectralBands);
        jPanel_spectralBands.setLayout(jPanel_spectralBandsLayout);
        jPanel_spectralBandsLayout.setHorizontalGroup(
            jPanel_spectralBandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 855, Short.MAX_VALUE)
        );
        jPanel_spectralBandsLayout.setVerticalGroup(
            jPanel_spectralBandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 124, Short.MAX_VALUE)
        );

        jPanel_prediction.add(jPanel_spectralBands);

        jPanel_opt.setPreferredSize(new java.awt.Dimension(855, 30));
        jPanel_opt.setLayout(new java.awt.GridLayout(1, 0));

        jCheckBox_actual.setSelected(true);
        jCheckBox_actual.setText("Actual");
        jPanel_opt.add(jCheckBox_actual);

        jCheckBox_est1.setSelected(true);
        jCheckBox_est1.setText("est.1");
        jPanel_opt.add(jCheckBox_est1);

        jCheckBox_est2.setSelected(true);
        jCheckBox_est2.setText("est.2");
        jPanel_opt.add(jCheckBox_est2);

        jCheckBox_est3.setSelected(true);
        jCheckBox_est3.setText("est.3");
        jPanel_opt.add(jCheckBox_est3);

        jCheckBox_avgEst.setSelected(true);
        jCheckBox_avgEst.setText("avg.est");
        jPanel_opt.add(jCheckBox_avgEst);

        jCheckBox_mse.setSelected(true);
        jCheckBox_mse.setText("MSE");
        jPanel_opt.add(jCheckBox_mse);

        jCheckBox_totalMSE.setSelected(true);
        jCheckBox_totalMSE.setText("total MSE");
        jPanel_opt.add(jCheckBox_totalMSE);

        jPanel_prediction.add(jPanel_opt);
        jPanel_prediction.add(jSlider_estimationBands);
        jPanel_prediction.add(jSlider_combination);

        jTabbedPane.addTab("Estimation Graph", jPanel_prediction);

        jPanel_fM.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel_fM.setLayout(new javax.swing.BoxLayout(jPanel_fM, javax.swing.BoxLayout.Y_AXIS));

        jPanel_featureMap.setPreferredSize(new java.awt.Dimension(855, 436));

        javax.swing.GroupLayout jPanel_featureMapLayout = new javax.swing.GroupLayout(jPanel_featureMap);
        jPanel_featureMap.setLayout(jPanel_featureMapLayout);
        jPanel_featureMapLayout.setHorizontalGroup(
            jPanel_featureMapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 855, Short.MAX_VALUE)
        );
        jPanel_featureMapLayout.setVerticalGroup(
            jPanel_featureMapLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 511, Short.MAX_VALUE)
        );

        jPanel_fM.add(jPanel_featureMap);
        jPanel_fM.add(jSlider_feature);

        jTabbedPane.addTab("Feature Map Graph", jPanel_fM);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Benchmark Name:");

        jLabel_benchNames.setText("jLabel2");

        jLabel2.setText("Test Size:");

        jLabel_benchTestSize.setText("jLabel2");

        jLabel3.setText("# of Random:");

        jLabel_benchRandom.setText("jLabel2");

        jLabel4.setText("# of Trials:");

        jLabel_benchTrial.setText("jLabel2");

        jLabel5.setText("# of Features:");

        jLabel_benchFeatures.setText("jLabel2");

        jLabel6.setText("# of Samples:");

        jLabel_benchSamples.setText("jLabel2");

        jLabel_benchNumbers.setText("jLabel2");

        jLabel7.setText("# of BenchMarks:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchNames, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchTrial)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchFeatures)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchSamples)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchNumbers)))
                .addGap(34, 34, 34)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchTestSize, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_benchRandom, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(145, 145, 145))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel_benchNames)
                    .addComponent(jLabel2)
                    .addComponent(jLabel_benchTestSize))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel_benchTrial)
                    .addComponent(jLabel5)
                    .addComponent(jLabel_benchFeatures)
                    .addComponent(jLabel6)
                    .addComponent(jLabel_benchSamples)
                    .addComponent(jLabel7)
                    .addComponent(jLabel_benchNumbers)
                    .addComponent(jLabel3)
                    .addComponent(jLabel_benchRandom))
                .addGap(0, 7, Short.MAX_VALUE))
        );

        jTable_benchTrainError.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable_benchTrainError.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane2.setViewportView(jTable_benchTrainError);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("Train Error BenchMark", jPanel2);

        jTable_benchTestError.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable_benchTestError.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane3.setViewportView(jTable_benchTestError);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("Test Error BenchMark", jPanel3);

        jTable_benchTime.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable_benchTime.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane4.setViewportView(jTable_benchTime);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("Time BenchMark", jPanel4);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane2)
                .addContainerGap())
        );

        jTabbedPane.addTab("BenchMark", jPanel6);

        jPanel_detail.setLayout(new java.awt.GridLayout(1, 0));

        jTextArea.setColumns(20);
        jTextArea.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jTextArea.setRows(5);
        jScrollPane1.setViewportView(jTextArea);

        jPanel_detail.add(jScrollPane1);

        jTabbedPane.addTab("Detail", jPanel_detail);

        jButton_save.setText("Save");
        jButton_save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_saveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel_optionsLayout = new javax.swing.GroupLayout(jPanel_options);
        jPanel_options.setLayout(jPanel_optionsLayout);
        jPanel_optionsLayout.setHorizontalGroup(
            jPanel_optionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_optionsLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton_save)
                .addContainerGap(788, Short.MAX_VALUE))
        );
        jPanel_optionsLayout.setVerticalGroup(
            jPanel_optionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_optionsLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton_save)
                .addContainerGap(502, Short.MAX_VALUE))
        );

        jTabbedPane.addTab("Options", jPanel_options);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    protected void savePlotModel() {
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new File(this.currDir));
        chooser.setDialogTitle("save plot model file as");
        chooser.setSize(new java.awt.Dimension(45, 37)); // Generated
        String row = jTextArea.getText();
        if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            String fullPath = file.getAbsolutePath();
            currFile = file.getName();
            Utils.writeOverToFileAppend(fullPath, row);
        }
    }

    private void jButton_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_saveActionPerformed
        savePlotModel();
    }//GEN-LAST:event_jButton_saveActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if (frm != null) {
            frm.setVisible(false);
            frm = null;
        }
    }//GEN-LAST:event_formWindowClosing

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        setChildFormLocation();
    }//GEN-LAST:event_formWindowActivated

    protected void setChildFormLocation() {
        if (frm == null) {
            return;
        }
        int xx = this.getLocation().x + (this.getWidth() - frm.getWidth()) / 2 + 50;
        int yy = this.getLocation().y + this.getHeight() / 2 + 70;
        //System.out.println(xx+":"+yy);
        frm.setLocation(xx, yy);
        frm.setVisible(true);
    }

    private void repaintTables() {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                jTable_benchTestError.setModel(getTableModel("test"));
                jTable_benchTrainError.setModel(getTableModel("train"));
                jTable_benchTime.setModel(getTableModel("time"));
            }
        });
    }

    public JSlider getJSlider_feature() {
        return jSlider_feature;
    }

    public JSlider getJSlider_estimationBands() {
        return jSlider_estimationBands;
    }

    public JPanel getJPanel_mergedGraph() {
        return jPanel_mergedGraph;
    }

    public JTextArea getJTextArea() {
        return jTextArea;
    }

    public JSlider getJSlider_classification() {
        return jSlider_classification;
    }

    public PanelFeatureMap getJPanel_classificationFeatureMap() {
        return jPanel_classificationFeatureMap;
    }

    public JTabbedPane getJTabbedPane() {
        return jTabbedPane;
    }

    public JPanel getJPanel_classificationGraph() {
        return jPanel_classificationGraph;
    }

    public JPanel getJPanel_estimationGraph() {
        return jPanel_estimationGraph;
    }

    public PanelFeatureMap getJPanel_spectralBands() {
        return jPanel_spectralBands;
    }

    public JPanel getJPanel_combinationGraph() {
        return jPanel_combination;
    }

    public PanelFeatureMap getJPanel_combinationBands() {
        return jPanel_combinationBands;
    }

    public JSlider getJSlider_combinationGraph() {
        return jSlider_combination;
    }

    public void loadBenchMarkData(Vector<String> v) {
        benchMarkData = v;
        String name = benchMarkData.get(0).split(":")[1];
        nTrials = Integer.parseInt(benchMarkData.get(1).split(":")[1]);
        nFeatures = Integer.parseInt(benchMarkData.get(2).split(":")[1]);
        nSamples = Integer.parseInt(benchMarkData.get(3).split(":")[1]);
        nTest = Integer.parseInt(benchMarkData.get(4).split(":")[1]);
        benchMarkStr = benchMarkData.get(5).split(":")[1];
        nBenchMark = Integer.parseInt(benchMarkData.get(6).split(":")[1]);
        nRandom = Integer.parseInt(benchMarkData.get(7).split(":")[1]);
        jLabel_benchNames.setText(name);
        jLabel_benchTrial.setText(nTrials + "");
        jLabel_benchFeatures.setText(nFeatures + "");
        jLabel_benchSamples.setText(nSamples + "");
        jLabel_benchNumbers.setText(nBenchMark + "");
        jLabel_benchTestSize.setText(nTest + "");
        jLabel_benchRandom.setText(nRandom + "");

        benchMarkColumns = benchMarkStr.split("\t");
        benchTrainError = new String[nTrials + 1][benchMarkColumns.length];
        benchTestError = new String[nTrials + 1][benchMarkColumns.length];
        benchTime = new String[nTrials + 1][benchMarkColumns.length];

        for (int i = 0; i < nTrials + 1; i++) {
            benchTestError[i] = benchMarkData.get(9 + i).split("\t");
            benchTrainError[i] = benchMarkData.get(11 + nTrials + i).split("\t");
            benchTime[i] = benchMarkData.get(13 + 2 * nTrials + i).split("\t");
        }
        repaintTables();
    }

    private String[] getMeanErrors(String[] names, String[] errors) {
        String[] ret = new String[2];
        double toplamR = 0;
        double toplamSR = 0;
        int k = 0;
        for (int i = 0; i < names.length; i++) {
            if (names[i].equals("Random")) {
                toplamR += Double.parseDouble(errors[i]);
                k++;
            }
            if (names[i].equals("Symmetric Random")) {
                toplamSR += Double.parseDouble(errors[i]);
            }
        }
        ret[0] = Math.round(toplamR / k * 100) / 100.0 + "";
        ret[1] = Math.round(toplamSR / k * 100) / 100.0 + "";
        return ret;
    }

    private String[] getMeanTimes(String[] names, String[] times) {
        String[] ret = new String[2];
        int toplamR = 0;
        int toplamSR = 0;
        int k = 0;
        for (int i = 0; i < names.length; i++) {
            if (names[i].equals("Random")) {
                toplamR += Integer.parseInt(times[i]);
                k++;
            }
            if (names[i].equals("Symmetric Random")) {
                toplamSR += Integer.parseInt(times[i]);
            }
        }
        ret[0] = toplamR / k + "";
        ret[1] = toplamSR / k + "";
        return ret;
    }

    public TableModel getTableModel(String type) {
        if (benchMarkColumns == null) {
            return null;
        }
        try {
            Object[][] data = null;
            if (type.equals("train")) {
                data = benchTrainError;
            } else if (type.equals("test")) {
                data = benchTestError;
            } else if (type.equals("time")) {
                data = benchTime;

            }
            //Object data[][] =(type.equals("error"))?benchTestError:benchTime;
            TableModel model = new DefaultTableModel(data, benchMarkColumns) {
            };
            return model;

        } catch (Exception e) {
            // TODO: handle exception
            return null;
        }
    }

    public PanelFeatureMap getJPanel_featureMap() {
        if (jPanel_featureMap == null) {
            jPanel_featureMap = new PanelFeatureMap();
            jPanel_featureMap.setLayout(new GridBagLayout());
        }
        return jPanel_featureMap;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameResultViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameResultViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameResultViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameResultViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrameResultViewer("").setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_save;
    private javax.swing.JCheckBox jCheckBox_actual;
    private javax.swing.JCheckBox jCheckBox_avgEst;
    private javax.swing.JCheckBox jCheckBox_est1;
    private javax.swing.JCheckBox jCheckBox_est2;
    private javax.swing.JCheckBox jCheckBox_est3;
    private javax.swing.JCheckBox jCheckBox_mse;
    private javax.swing.JCheckBox jCheckBox_totalMSE;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel_benchFeatures;
    private javax.swing.JLabel jLabel_benchNames;
    private javax.swing.JLabel jLabel_benchNumbers;
    private javax.swing.JLabel jLabel_benchRandom;
    private javax.swing.JLabel jLabel_benchSamples;
    private javax.swing.JLabel jLabel_benchTestSize;
    private javax.swing.JLabel jLabel_benchTrial;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private panel.PanelFeatureMap jPanel_classificationFeatureMap;
    private javax.swing.JPanel jPanel_classificationGraph;
    private javax.swing.JPanel jPanel_combination;
    private panel.PanelFeatureMap jPanel_combinationBands;
    private javax.swing.JPanel jPanel_combinationGraph;
    private javax.swing.JPanel jPanel_detail;
    private javax.swing.JPanel jPanel_errorFeature;
    private javax.swing.JPanel jPanel_estimationGraph;
    private javax.swing.JPanel jPanel_fM;
    private panel.PanelFeatureMap jPanel_featureMap;
    private javax.swing.JPanel jPanel_mergedGraph;
    private javax.swing.JPanel jPanel_opt;
    private javax.swing.JPanel jPanel_options;
    private javax.swing.JPanel jPanel_prediction;
    private panel.PanelFeatureMap jPanel_spectralBands;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSlider jSlider_classification;
    private javax.swing.JSlider jSlider_combination;
    private javax.swing.JSlider jSlider_combinationGraph;
    private javax.swing.JSlider jSlider_estimationBands;
    private javax.swing.JSlider jSlider_feature;
    private javax.swing.JTabbedPane jTabbedPane;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTable jTable_benchTestError;
    private javax.swing.JTable jTable_benchTime;
    private javax.swing.JTable jTable_benchTrainError;
    private javax.swing.JTextArea jTextArea;
    // End of variables declaration//GEN-END:variables
}
